<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- ssx --%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath %>">
<title>今日特价</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%-- 引用layui.css --%>
<link rel="stylesheet" type="text/css" href="<%=basePath %>js/layui/css/layui.css" />
<link rel="stylesheet" type="text/css"href="<%=basePath %>css/common.css" />
</head>
<body>
	<div class="ibox">
		<div class="ibox-content bodycss">
			
			<section class="panel panel-padding ">
			
			<table class="layui-table"
			       
				lay-data="{
	                        id:'menuTeble',
	                        width:'auto',
	                        url:'today/list.do',
	                        page:false,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10}"
				lay-filter="popedomLay"
				
				>
				
				<thead >
					<tr>
						<th lay-data="{type:'numbers', width:50}">序号</th>
						<th lay-data="{field:'title', width:350,align:'center'}">特价主题</th>
						<th lay-data="{field:'commodity', width:350,align:'center'}">特价商品</th>
						<th lay-data="{field:'price', width:330,align:'center'}">价格</th>
						<th lay-data="{field:'company', width:330,align:'center'}">单位</th>
						<th lay-data="{fixed: 'right', width:300, align:'center', toolbar: '#popedomBar'}">操作</th>
					</tr>
				</thead>
				
			</table>
			
			</section>
		</div>
	</div>
	
	<script type="text/html" id="popedomBar">
			
            <a class="layui-btn layui-btn-xs layui-btn-radius"  lay-event="edit" >修改信息</a>
			
    </script>
	<script type="text/javascript" src="<%=basePath %>js/layui/layui.js"></script>
	<script type="text/javascript">
	
	layui.config({
	    base: "<%=basePath%>/js/common/"
	}).use(["common", "element", "layer", "form", "table", "jquery"], function(){
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			layui.common.init();			
			/**
			 * 监听刷新表格
			 */
		form.on('submit(seach)', function(data){
			// layer.msg(JSON.stringify(data.field));
			table.reload('menuTeble', {
				where: data.field,
				page : {
					curr : 1
				}
			});
			return false;
		});
		
		
		/*
		     监听行事件
		
		**/	
		 table.on('tool(popedomLay)', function(obj){
			    var data = obj.data;
			    var id = data.id;
			    var title = data.title;
			    var commodity = data.commodity;
			    var price = data.price;
			    var company = data.company;
			    
			    if(obj.event === 'edit'){
			    	layer.open({
	                    type: 2,
	                    title: '今日特价',
	                    content: 'todays/update.do',
	                    area: ['650px', '430px'],
	                    anim: 5,
	                    isOutAnim: true,
	                    maxmin: true,
	                    resize: false,
	                    moveOut: true,
	                    zIndex: 99999,
	                    skin: 'yourclass',
	                    success: function(layero, index){
	                    	var body = layer.getChildFrame('body', index);
	                        body.contents().find("INPUT[name='id']").val(id);
	                        body.contents().find("INPUT[name='title']").val(title);
	                        body.contents().find("INPUT[name='commodity']").val(commodity);
	                        body.contents().find("INPUT[name='price']").val(price);
	                        body.contents().find("INPUT[name='company']").val(company); 
	                    },
	                    end : function(){
	                    	table.reload("menuTeble");
	                    }

			    	});
			    }
			  });

			
		       
	});
</script>

</body>
</html>
